<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>
  <%@ include file="/common/extjs.jsp"%>
<script type="text/javascript" >

 /** 
 * 附件管理窗口
 */
 function showUploadWin(no)  {
	    
	 var projectid ='${(empty param.projectId) ?(projectInfo.projectId):(param.projectId)}';
  	 var fid ='${param.fid}';
        if(no ==1){
           var tableName = "detectionaftersupervisionTender";
           var tableField = [['detectionaftersupervisionTender','《公路工程完工后交工验收检测申请》']
  					 ];
         projectAttachment.init(projectid,fid,tableName,tableField);
         projectAttachment.showUploadJquery("《公路工程完工后交工验收检测申请》");
        }else if(no ==2){
        	var tableName = "detectionConstructQualifiedMaterial";
            var tableField = [['detectionConstructQualifiedMaterial','施工自检合格资料']
    					 ];
           projectAttachment.init(projectid,fid,tableName,tableField);
           projectAttachment.showUploadJquery("施工自检合格资料 ");
          }else if(no ==3){
        	  var tableName = "detectionSupervisorCheckPass";
          var tableField = [['detectionSupervisorCheckPass','监理抽检合格资料 ']
  					 ];
         projectAttachment.init(projectid,fid,tableName,tableField);
         projectAttachment.showUploadJquery("监理抽检合格资料");
        }
   }  


 
Ext.onReady(function(){
  Ext.QuickTips.init();
  var myData = [
                ['1','1','《公路工程完工后交工验收检测申请》'],
                ['2','2','施工自检合格资料'],
                ['3','3','监理抽检合格资料']
    ];
     // Record
    MpSupervisionAffix = Ext.data.Record.create([
                                    {name: 'no', type: 'string'},
    								{name: 'kind', type: 'string'},
    								{name: 'file', type: 'string'},
    ]);
    
    // create the data store
    var store = new Ext.data.Store({
        reader: new Ext.data.ArrayReader(
        {
            idIndex: 0  // id for each record will be the first element
        },MpSupervisionAffix)
    });
  store.loadData(myData);
  
  var cm = new Ext.grid.ColumnModel([
       {header: "序号", width: 45, dataIndex: 'no'},
       {header: "kind", width: 75, dataIndex: 'kind',hidden: true},
       {id:'file',header: "完工后交工验收检测（公路）", width: 360, dataIndex: 'file',renderer:Jinyi.project.Format.textAreaRenderer},
       {
					           header:  	'资料查询',
							   align: 'center',
								dataIndex : '',
					           renderer: function(value, metaData, record, rowIndex, colIndex, store) {
					            var no = record.get('no');
					          //  if(no == 2){
					            //    return; 
					           // }
					            var href = "<span class='upload_renderer'><a href='javascript:showUploadWin(\""+no+"\")' >查看资料</a></span>";
					            return href;
					           },  
					           width: 		180
     	 }
  
  ]);
  
   // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        cm: cm,
        tbar:[{text:"批量下载",handler:function(){
         	 var projectid ='${(empty param.projectId) ?(projectInfo.projectId):(param.projectId)}';
         	 var fid ='${param.fid}';
        	location.href = "${ctx}/attachment/attachment!downloadMany.action?tableId="+fid+"&partId="+projectid;
        }}],
        width: 800,
        height: 500,
        sm:	new Ext.grid.RowSelectionModel({singleSelect:true}),
        frame:true,
		viewConfig: {
       		forceFit: false,
        	getRowClass: function(record, index) {
   			 }
   			},
        loadMask:true, 
        autoExpandColumn: 'file'
    });
    
    var viewport = new Ext.Viewport({
        layout:'fit',
        items:[grid]
        });
})
</script>
<body>
<div id="mpSupervisionAffixGrid"></div>
</body>

